<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:t="http://www.pagac.cz/jsf"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
 <h:head></h:head>
 <h:body>
    <ui:composition template="/WEB-INF/templates/template-insystem.xhtml">

        <!-- Toolbar -->
        <ui:define name="toolbar-place">
            <t:toolbar>
                <t:icon iconName="home" action="goHome" label="#{msgs['toolbar.home']}" />
                <t:icon iconName="print" action="printPage" label="#{msgs['toolbar.print']}" />
                <t:separator />
                <t:icon iconName="add" action="../register"
                        label="#{msgs['toolbar.add']}" sideLabel="true" />
                <t:separator />
                <!-- Granularity selection -->
                <t:icon iconName="more" action="more" backingBean="#{adminManager}" label="#{msgs['toolbar.more']}"
                        bean="true" ajaxExecute="@this" ajaxRender="@all" formId="moreNavLink"
                        renderedBean="#{adminManager.paginator}" renderedAction="moreSafe" />
                <t:icon iconName="less" action="less" backingBean="#{adminManager}" label="#{msgs['toolbar.less']}"
                        bean="true" ajaxExecute="@this" ajaxRender="@all" formId="lessNavLink"
                        renderedBean="#{adminManager.paginator}" renderedAction="remainsSomething" />
                <t:separator />
                <!-- AJAX navigation -->
                <t:icon iconName="first" action="first" backingBean="#{adminManager}" label="#{msgs['toolbar.first']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="firstNavLink"
                    renderedBean="#{adminManager.paginator}" renderedAction="hasPreviousPage" />
                <t:icon iconName="prev" action="previous" backingBean="#{adminManager}" label="#{msgs['toolbar.previous']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="prevNavLink"
                    renderedBean="#{adminManager.paginator}" renderedAction="hasPreviousPage" />
                <t:textIcon>
                    <h:outputFormat value="&nbsp;#{msgs['app.paging.displayInfo']}">
                        <f:param value="#{adminManager.paginator.pageFirstItem + 1}" />
                        <f:param value="#{adminManager.paginator.pageLastItem + 1}" />
                        <f:param value="#{adminManager.paginator.itemsCount}" />
                    </h:outputFormat>
                    <h:outputText value=" (#{msgs['app.paging.page']} #{adminManager.paginator.actualPage + 1}) " />
                </t:textIcon>
                <t:icon iconName="next" action="next" backingBean="#{adminManager}" label="#{msgs['toolbar.next']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="nextNavLink"
                    renderedBean="#{adminManager.paginator}" renderedAction="hasNextPage" />
                <t:icon iconName="last" action="last" backingBean="#{adminManager}" label="#{msgs['toolbar.last']}"
                    bean="true" ajaxExecute="@this" ajaxRender="@all" formId="lastNavLink"
                    renderedBean="#{adminManager.paginator}" renderedAction="hasNextPage" />
            </t:toolbar>
        </ui:define>

        <!-- Title -->
        <ui:define name="content-title">
            <h1>#{msgs["user.list.page-title"]}</h1>
        </ui:define>

        <!-- Content -->
        <ui:define name="content">
            <c:choose>
                <c:when test="#{adminManager.usersCount > 0}">

                    <!-- Users Listing -->
                    <h:outputStylesheet name="cssTable.css" library="css" />
                    <h:dataTable id="userTable"
                                 value="#{adminManager.list}"
                                 var="user"
                                 styleClass="listing"
                                 rowClasses="odd,even"
                                 columnClasses="name, login, email, role, actions">
                        <t:column  headerCssStyle="listing-header" entity="${user}"
                                   fieldName="name" backingBean="#{adminManager}"
                                   label="#{msgs['user.list.name']}">
                            #{user.name}
                        </t:column>
                        <t:column sort="false" fieldName="login"
                                  label="#{msgs['user.list.login']}">
                            #{user.login}
                        </t:column>
                        <t:column sort="false" fieldName="contact"
                                  label="#{msgs['user.list.contact']}">
                            <a href="mailto:#{user.email}">#{user.email}</a><br />

                        </t:column>
                        <t:column sort="false" fieldName="role"
                                  label="#{msgs['user.list.role']}">
                            #{user.role}
                        </t:column>

                        <t:columnCommand label="#{msgs['user.list.actions']}">
                            <h:commandButton value="#{msgs['user.list.actions.edit']}" action="#{adminManager.getEdit}" />
                            <h:commandButton value="#{msgs['user.customer.list.actions.remove']}" action="#{adminManager.remove}"
                                             onclick="return confirm('#{msgs['user.list.list.actions.removeConfirm']}');">
                                <f:ajax execute="@this" render="@all" />
                            </h:commandButton>
                        </t:columnCommand>
                    </h:dataTable>

                    <!-- AJAX navigation -->
                    <p class="statusPageInfoBox">
                        <h:commandLink id="prevLink" action="#{adminManager.previous}"
                                        value="&#9668; #{msgs['app.paging.nextLabel']}"
                                        rendered="#{adminManager.paginator.hasPreviousPage}"
                                        styleClass="prevLink">
                            <f:ajax execute="@this" render="@all" onevent="showIndicator" />
                        </h:commandLink>

                        <h:outputFormat value="&nbsp;#{msgs['app.paging.displayInfo']}&nbsp;">
                            <f:param value="#{adminManager.paginator.pageFirstItem + 1}" />
                            <f:param value="#{adminManager.paginator.pageLastItem + 1}" />
                            <f:param value="#{adminManager.paginator.itemsCount}" />
                        </h:outputFormat>

                        &nbsp;&nbsp;&nbsp;

                        <h:outputText value=" #{msgs['app.paging.page']} #{adminManager.paginator.actualPage + 1} " />

                        <h:commandLink id="nextLink" action="#{adminManager.next}"
                                       value="#{msgs['app.paging.nextLabel']} &#9658;"
                                       rendered="#{adminManager.paginator.hasNextPage}"
                                       styleClass="nextLink">
                            <f:ajax execute="@this" render="@all" onevent="showIndicator" />
                        </h:commandLink>
                    </p>
                </c:when>
                <c:otherwise>
                    <p class="warning-messages-noitems">
                        #{msgs['app.listing.no-records']}
                    </p>
                </c:otherwise>
            </c:choose>
       </ui:define>

    </ui:composition>

</h:body>
</html>
